import { createRouter, createWebHashHistory } from "vue-router";

const base = [
  {
    path: "/",
    name: "root",
    redirect: "/login",
    meta: { layout: "blank" },
  },
  {
    path: "/login",
    name: "login",
    component: () => import("../views/login/index.vue"),
    meta: { layout: "blank" },
  },
];

const error = {
  path: "/:pathMatch(.*)*",
  name: "error",
  component: () => import("../views/error/index.vue"),
  meta: { layout: "blank" },
};

export const dynamic = [
  {
    path: "/home",
    name: "home",
    component: () => import("../views/home/index.vue"),
    meta: { layout: "content", title: "首页", icon: "build" },
  },
  {
    path: "/specs",
    name: "specs",
    component: () => import("../views/specs/index.vue"),
    meta: { layout: "content", title: "包规管理", icon: "row" },
  },
  {
    path: "/formula",
    name: "formula",
    component: () => import("../views/formula/index.vue"),
    meta: { layout: "content", title: "配方管理", icon: "list" },
  },
  {
    path: "/user",
    name: "user",
    component: () => import("../views/user/index.vue"),
    meta: { layout: "content", title: "用户管理", icon: "user" },
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes: [...base, ...dynamic, error],
});

export default router;
